class Stack {
	items = [];  // 使用数组来存储栈的元素
	// 压栈操作
	push(item) {
		this.items.push(item);
	}
	// 弹出栈顶元素
	pop() {
		return this.items.pop();
	}
	// 返回栈顶元素但不移除
	peek() {
		return this.items[this.items.length - 1];
	}
  // 检查栈是否为空
	isEmpty() {
		return this.items.length === 0;
	}
  // 返回栈中元素的个数
	size() {
		return this.items.length;
	}
  // 清空栈
	clear() {
		this.items = [];
	}
}
const stack = new Stack()
console.log(stack.isEmpty());
stack.push(1)
stack.push(4)
stack.push(5)
console.log(stack.isEmpty());
console.log(stack.pop());
console.log(stack.size());
stack.clear()
console.log(stack.isEmpty());


